﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Site_Product_ProductDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		this.Form.Action = "Site/ProductDetail.aspx";
		if (!IsPostBack)
		{
			Session["ProductID"] = Request.QueryString["ProductID"];
			productDetails.DataSource = EF_Product.GetProductById(Session["ProductID"].ToString());
			productDetails.DataBind();
		}
    }

	protected void AddToCartButton_Click(object sender, EventArgs e)
	{
		// Retrieve ProductID from the query string
		string productId = Session["ProductID"].ToString();
		// Retrieve the selected product options
		ShoppingCartAccess.AddItem(productId);
		Response.Redirect(Request.RawUrl + "?ProductID=" + productId);
	}
}